class Commodity:
  def __init__(self, commodity_name, commodity_price):
    self.commodity_name = commodity_name
    self.commodity_price = commodity_price

  def __str__(self):
    return f"商品名：{self.commodity_name}，商品价格{self.commodity_price}"

  def addCart(self, s):
    s.addCommodity(self)


class ShoppingCart:
  def __init__(self):
    self.commodity_list = []

  def addCommodity(self, commodity):
    self.commodity_list.append(commodity)

  def showAll(self):
    for i in range(len(self.commodity_list)):
      print(self.commodity_list[i])

# 实例化商品
c1 = Commodity("bulb", 12)
c2 = Commodity("ice_creame", 3)
# 实例化购物车
s1 = ShoppingCart()
s2 = ShoppingCart()
# 添加购物车
s1.addCommodity(c1)
c2.addCart(s2)
c1.addCart(s2)
# 打印商品列表
s1.showAll()
print()
s2.showAll()
